//
// Created by mongobaba on 2021/6/8.
//

#include "unit_test.h"
#include "json_validator.h"

// 特殊情况
TEST(parse_elements_empty) {
    json_validator validator("");
    ASSERT_EQ(false, validator.parse_elements());
    ASSERT_EQ(std::string(""), validator.left());
}

// 单个element
TEST(parse_elements_single_element) {
    json_validator validator("1x");
    ASSERT_EQ(true, validator.parse_elements());
    ASSERT_EQ(std::string("x"), validator.left());
}

// 多个element
TEST(parse_elements_multi_elements) {
    // 包括逗号前后都无空白，前面有空白，后面有空白，前后都有空白几种情况
    json_validator validator("1,2 ,3, 4 , 5x");
    ASSERT_EQ(true, validator.parse_elements());
    ASSERT_EQ(std::string("x"), validator.left());
}

// 异常情况，逗号后面无element
TEST(parse_elements_no_element_after_comma) {
    json_validator validator("1,x");
    ASSERT_EQ(false, validator.parse_elements());
    ASSERT_EQ(std::string("x"), validator.left());
}
